<!DOCTYPE html>
<html>

<head>
    <title>申请详情</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="../../static/orderscreate/css/bootstrap.min.css" rel="stylesheet">
    <link href="../../static/orderscreate/css/fileinput.min.css" rel="stylesheet">
    <link href="../../static/orderscreate/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
{#    <link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">#}
    <link href="../../static/orderscreate/form_builder/animate.min.css" rel="stylesheet">
    <link href="../../static/orderscreate/form_builder/summernote.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../../static/system_setup/flow_cerate/css/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../../static/system_setup/flow_cerate/css/style.css">
    <link href="../../static/orderscreate/form_builder/style.min862f.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../../static/orderscreate/css/index.css">
    <script src="../../static/system_setup/js/jquery-1.10.2.min.js"></script>
    <script src="../../static/orderscreate/javascript/bootstrap.min.js"></script>
    <script src="../../static/orderscreate/javascript/fileinput.min.js"></script>
    <script src="../../static/orderscreate/javascript/bootstrap-datetimepicker.min.js"></script>
    <script src="../../static/orderscreate/javascript/distpicker.data.min.js"></script>
    <script src="../../static/orderscreate/javascript/distpicker.min.js"></script>
    <script src="../../static/orderscreate/javascript/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="../../static/orderscreate/javascript/zh.js"></script>
    <script src="../../static/orderscreate/javascript/jquery-ui.min.js"></script>
    <script src="../../static/orderscreate/form_builder/beautifyhtml.js"></script>
    <script src="../../static/orderscreate/javascript/index.js"></script>
    <style>
        .radio-inline_1 {
            margin-top: 7px;
            padding-right: 20px;
        }

        .form-flow {
            display: inline-block;
            width: 100px;
            vertical-align: top;
            text-align: center;
            font-size: 14px;
            cursor: pointer;
        }

        .form-flow-add-color {
            border-bottom: #00a0e9 solid 1px;
            color: #00a0e9;
        }

        .li-class {
            list-style: none;
            margin-top: 2%;
            color: #0b0b0b;
            cursor: pointer;
        }

        .add_background {
            background: #A9A9A9;
        }

        tr {
            height: 35px;
        }

        th {
            text-align: center;
        }

        table {
            table-layout: fixed;
        }

        td:first-child, th:first-child {
            position: sticky;
            left: 0; /* 首行永远固定在左侧 */
            z-index: 1;
        }

        thead tr th {
            position: sticky;
            top: 0; /* 列首永远固定在头部  */
            background-color: #E8E8E8;
        }

        th:first-child {
            z-index: 2;
        }

        .search1 {
            width: 95%;
            display: flex;
            float: right;
            margin: 5.5px 0;
            margin-right: 1%;
            /*border: 1px solid red;*/
        }

        .search1 input {
            vertical-align: middle;
            float: left;
        / / 左浮动 flex: 4;
            height: 29px;
            width: 77%;
            outline: none;
            border: 1px solid #0070c1;
            box-sizing: border-box;
        / / 盒子模型，怪异IE盒子模型，width = content + border * 2 + padding * 2 padding-left: 10 px;
            border-bottom-left-radius: 5px;
            border-top-left-radius: 5px;
        }

        .search1 button {
            float: right;
            flex: 1;
            height: 29px;
            width: 23%;
            line-height: 29px;
            background-color: #0070c1;
            color: white;
            border-style: none;
            outline: none;
            border-bottom-right-radius: 5px;
            border-top-right-radius: 5px;
        }

        .search1 button i {
            font-style: normal;
        }

        .search1 button:hover {
            font-size: 16px;
        }

        .add_background {
            background: #A9A9A9;
        }

        #process_type {
            border: none;

        }

        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }

        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }

        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }
    </style>
</head>

<body style="background-color:#f7f5f6;">
<div id="new_models" style="width: 80%;height: 80%;position: absolute;display: none;">
    <div style="width: 700px;height: 500px;background: #F5F5F5;z-index: 10100;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
        <div id="box"
             style="width: 100%;height: 50px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;">
            <h5 id="modal-title" class="modal-title"
                style="line-height: 50px;width: 15%;margin-left: 1%;display: inline-block;">流程审批</h5>
            <span onclick="close_models()" style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i
                    class="iconfont icon-quchu"></i></span>
        </div>
        <div style="height: 300px;width: 100%;padding-top: 2%;padding-left: 2%;">
            <div>
                <label style="vertical-align: top;">审批</label>
                <input type="radio" name="approve" value="audit" checked>同意
                <input style="margin-left: 3%;" type="radio" name="approve" value="draft">不同意
            </div>

            <div style="margin-top: 2%;width: 100%;">
                <label style="vertical-align: top;">意见</label>
                <textarea name="" id="opinion_detail" cols="30" rows="15" style="width: 90%;padding:1%;"></textarea>
            </div>
        </div>
        <hr>
        <div style="width: 100%;height: 50px;text-align: right;padding-right: 2%;margin-top: 10%">
            <button onclick="summit_data()"
                    style="width: 100px;height: 30px;border: #dfdfdf solid 1px;margin-top: 10px;border-radius: 3px;background: #1E90FF;color: white;">
                提交
            </button>
        </div>
    </div>
</div>

<div>
    <div id="form-tab" onclick="label_switching(this.id)" class="form-flow form-flow-add-color">申请详情</div>
    <div id="flow-tab" onclick="label_switching(this.id)" class="form-flow">审批流程
    </div>
    {% if data.is_audit == 'true' %}
        <div id="approver_but" style="float: right;width: 110px;height: 40px;text-align: center;">
            <button onclick="online_tag()"
                    style="width: 100px;height: 30px;line-height: 27px;border: #1E90FF solid 1px;background: #1E90FF;color: white;margin-top: 5px;border-radius: 3px;">
                审批
            </button>
        </div>
    {% endif %}
    {% if data.is_edit == 'true' %}
        <div id="approver_but_0" style="float: right;width: 110px;height: 40px;text-align: center;">
            <button onclick="do_edit()"
                    style="width: 100px;height: 30px;line-height: 27px;border: #1E90FF solid 1px;background: #1E90FF;color: white;margin-top: 5px;border-radius: 3px;">
                提交
            </button>
        </div>
    {% endif %}

    <div id="form_design" class="container-fluid" style="padding:0; margin:0;">
        <div class="row-fluid clearfix">
            <div class="col-md-12 column">
                <div style="width:1080px; margin:0 auto; margin-top:20px;">
                    <div class="conference-cont">
                        <div class="wrapper wrapper-content">
                            <div class="row"
                                 style="border-left: 2px dashed rgba(0,0,0,0.12);border-right: 2px dashed rgba(0,0,0,0.12);border-bottom: 2px dashed rgba(0,0,0,0.12);">
                                <div id="colzuo" class="col-sm-12" style="border-right: 2px dashed rgba(0,0,0,0.12);">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-content">
                                            <div class="row form-body form-horizontal m-t" id="customer_form">
                                                {% autoescape off %}{{ data.business_html }}{% endautoescape %}
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="flow_design" class="container-fluid" style="padding:0; margin:0;display: none;">
    <div style="width: 100%">
        <hr>
        <table style="border: #a6a9ad solid 1px ;width: 98%; margin-left: 1%">
            <thead>
            <tr style="border: #a6a9ad solid 1px">
                <th scope="col" style="text-align: center; width:15%; border: #a6a9ad solid 1px">审批人</th>
                <th scope="col" style="text-align: center; width:15%; border: #a6a9ad solid 1px">审核状态</th>
                <th scope="col" style="text-align: center; width:10%; border: #a6a9ad solid 1px">节点</th>
                <th scope="col" style="width:25%; border: #a6a9ad solid 1px">审批意见</th>
                <th scope="col" style="width:15%; border: #a6a9ad solid 1px">审批时间</th>
                <th scope="col" style="width:10%; border: #a6a9ad solid 1px">签名</th>
            </tr>
            </thead>
            <tbody>
            {% for audit in data.audit_list %}
                <tr style="border: #a6a9ad solid 1px">
                    <td style="text-align: center; border: #a6a9ad solid 1px; height: auto">{{ audit.audit_user }}</td>
                    <td style="text-align: center; border: #a6a9ad solid 1px; height: auto">{{ audit.state }}</td>
                    <td style="text-align: center; border: #a6a9ad solid 1px; height: auto">{{ audit.node }}</td>
                    <td style="border: #a6a9ad solid 1px; height: auto; padding-left: 1%">{{ audit.audit_note }}</td>
                    <td style="text-align: center; border: #a6a9ad solid 1px; height: auto">{{ audit.audit_time }}</td>
                    <td style="text-align: center; border: #a6a9ad solid 1px; height: auto"><img
                            src="{{ audit.signature_picture }}" height="30px"></td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript" src="../../static/system_setup/flow_cerate/js/jquery.jsPlumb.min.js"></script>
<script type="text/javascript" src="../../static/system_setup/flow_cerate/js/index.js"></script>
<script>
    //时间初始化
    $(".form_datetime").datetimepicker({
        language: 'zh-CN', //日期
        format: "yyyy/mm/dd hh:ii",
        initialDate: new Date(), //初始化当前日期
        autoclose: true, //选中自动关闭
        todayBtn: true //显示今日按钮
    });
    const uuid = "{{ data.uuid | safe }}"
    window.onload = function () {
        var data =
        {{ data.data_html | safe }}
        var file_list =
        {{ data.file_list | safe }}
        var is_edit = "{{ data.is_edit }}"
        var is_audit = "{{ data.is_audit }}"
        for (var i = 0; i < data.length; i++) {
            var record = data[i]
            var id = record['id']
            $('.col-sm-3').css('display', 'none')
            if (record['type'] === 'checkbox') {
                if (is_edit == 'false') {
                    $("input[type=checkbox]").attr("disabled", "disabled")
                }
                $("#" + String(id)).attr("checked", true)
            } else if (record['type'] === 'radio') {
                $("input[name='radio_button'][value='" + record['value'] + "']").prop("checked", true);
                if (is_edit == 'false') {
                    $("input[type=radio]").attr("disabled", "disabled")
                }
            } else if (record['type'] === 'select') {
                if (is_edit == 'false') {
                    $("#" + String(id)).attr("disabled", "disabled")
                }
                $("#" + String(id)).val(record['value'])
            } else if (record['type'] === 'file') {
                if (is_edit == 'false') {
                    $("#upload_file").css("display", "none")
                }
            } else {
                if (is_edit == 'false') {
                    $("#" + String(id)).attr("disabled", "disabled")
                }
                document.getElementById(id).value = String(record.value)
            }
        }
        for (var i = 0; i < file_list.length; i++) {
            creat_table(file_list[i], "party_main")
        }
    }

    function online_tag() {
        document.getElementById("new_models").style.display = "table";
        $("input[name='approve']").removeAttr("disabled");
        var box = document.getElementById('box');
        var isDown = false;
        var mouse = {};
        box.onmousedown = (e) => {
            isDown = true;
            isDown_1 = false;
            //保存初始位置
            mouse = {
                startX: e.clientX,
                startY: e.clientY,
                offsetLeft: box.offsetLeft,
                offsetTop: box.offsetTop,
            }
        };

        box.onmousemove = (e) => {
            if (!isDown) {
                return
            }
            //计算偏移位置
            var offsetLeft = mouse.offsetLeft + e.clientX - mouse.startX;
            var offsetTop = mouse.offsetTop + e.clientY - mouse.startY;

            //设置偏移距离的范围[0,window.innerWidth - 400]
            offsetLeft = Math.max(0, Math.min(offsetLeft, window.innerWidth - 400));
            offsetTop = Math.max(0, Math.min(offsetTop, window.innerHeight - 400));

            box.style.left = offsetLeft + 'px';
            box.style.top = offsetTop + 'px';

        };
        //当鼠标滑的太快时，容易移出box，所以在window上监听此事件
        window.onmouseup = () => {
            isDown = false;
            box.style.cursor = 'default';
            mouse = null;
        };
    }

    function summit_data() {
        var present_id = window.location.href.split("id=")[1].replace("#", '');
        var approve = $("input[type=radio][name=approve]:checked").val();
        var audit_note = document.getElementById("opinion_detail").value;

        if (approve === "draft") {
            if (!audit_note) {
                alert("不同意请填写理由！");
                return false
            }
        }
        // document.getElementById("loading").style.display = "inline-block";
        var xhr = new XMLHttpRequest();
        var local_host = window.location.host;          // 获取当前IP
        xhr.open('post', "/system-setup/low_code_bill_detail_view");
        xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
        xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
        xhr.send("id=" + present_id + "&state=" + String(approve) + "&audit_note=" + String(audit_note));
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    // document.getElementById("loading").style.display = "none";
                    var JsonDate = JSON.parse(xhr.responseText);
                    if (JsonDate["code"] === 200) {
                        alert("审批成功");
                        window.parent.location.reload()
                        {#window.location.href="/personal-center/process_management.html?type=我的待办&folw_type=&folw=&page=1&page_size=20&wd=";#}
                    } else {
                        alert(JsonDate["message"]);
                    }
                }
            }
        };
    }

    function close_models() {
        document.getElementById("new_models").style.display = "none";
    }


    function label_switching(ele_id) {
        if (ele_id === 'form-tab') {
            document.getElementById('form-tab').className = 'form-flow form-flow-add-color'
            document.getElementById('flow-tab').className = 'form-flow'
            document.getElementById('form_design').style.display = 'inline-block';
            document.getElementById('flow_design').style.display = 'none';
        } else {
            document.getElementById('flow-tab').className = 'form-flow form-flow-add-color'
            document.getElementById('form-tab').className = 'form-flow'
            document.getElementById('form_design').style.display = 'none';
            document.getElementById('flow_design').style.display = 'inline-block';
        }
    }

    function creat_table(JsonData, tbody_id) {
        var t_table = document.getElementById(tbody_id);
        var local_host = window.location.host;
        if (Array.isArray(JsonData["pdf_path"])) {
            for (var i = 0; i < JsonData["pdf_path"].length; i++) {
                var tr = document.createElement("tr");
                var td1 = document.createElement("td");
                var td2 = document.createElement("td");
                var td3 = document.createElement("td");
                var td4 = document.createElement("td");
                var td5 = document.createElement("td");
                var td6 = document.createElement("td");
                td1.innerHTML = t_table.children.length + 1;
                td1.style.textAlign = "center";
                td1.style.border = "#cccccc solid 1px";
                td1.style.borderTop = "none";
                td2.innerHTML = JsonData["file_name"];
                td2.style.paddingLeft = "1%";
                td2.style.border = "#cccccc solid 1px";
                td2.style.borderLeft = "none";
                td2.style.borderTop = "none";
                td3.innerHTML = JsonData["file_size"];
                td3.style.textAlign = "center";
                td3.style.border = "#cccccc solid 1px";
                td3.style.borderLeft = "none";
                td3.style.borderTop = "none";
                td4.innerHTML = JsonData["upload_time"];
                td4.style.textAlign = "center";
                td4.style.border = "#cccccc solid 1px";
                td4.style.borderLeft = "none";
                td4.style.borderTop = "none";
                td5.innerHTML = JsonData["uploader"];
                td5.style.textAlign = "center";
                td5.style.border = "#cccccc solid 1px";
                td5.style.borderLeft = "none";
                td5.style.borderTop = "none";

                td6.innerHTML = "<a target='_blank' href='" + JsonData["file_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData[i]["id"] + "\")'>删除</a>";
                td6.style.textAlign = "center";
                td6.style.border = "#cccccc solid 1px";
                td6.style.borderLeft = "none";
                td6.style.borderTop = "none";
                tr.appendChild(td1);
                tr.appendChild(td2);
                tr.appendChild(td3);
                tr.appendChild(td4);
                tr.appendChild(td5);
                tr.appendChild(td6);
                t_table.appendChild(tr);
            }
            if (JsonData["pdf_path"].length > 1) {
                document.getElementById("del_adjunct").style.display = 'block';
            }
        } else {
            var tr = document.createElement("tr");
            var td1 = document.createElement("td");
            var td2 = document.createElement("td");
            var td3 = document.createElement("td");
            var td4 = document.createElement("td");
            var td5 = document.createElement("td");
            var td6 = document.createElement("td");
            td1.innerHTML = t_table.children.length + 1;
            td1.style.textAlign = "center";
            td1.style.border = "#cccccc solid 1px";
            td1.style.borderTop = "none";
            td2.innerHTML = JsonData["file_name"];
            td2.style.paddingLeft = "1%";
            td2.style.border = "#cccccc solid 1px";
            td2.style.borderLeft = "none";
            td2.style.borderTop = "none";
            td3.innerHTML = JsonData["file_size"];
            td3.style.textAlign = "center";
            td3.style.border = "#cccccc solid 1px";
            td3.style.borderLeft = "none";
            td3.style.borderTop = "none";
            td4.innerHTML = JsonData["upload_time"];
            td4.style.textAlign = "center";
            td4.style.border = "#cccccc solid 1px";
            td4.style.borderLeft = "none";
            td4.style.borderTop = "none";
            td5.innerHTML = JsonData["uploader"];
            td5.style.textAlign = "center";
            td5.style.border = "#cccccc solid 1px";
            td5.style.borderLeft = "none";
            td5.style.borderTop = "none";
            td6.innerHTML = "<a target='_blank' href='" + JsonData["file_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["id"] + "\")'>删除</a>";
            td6.style.textAlign = "center";
            td6.style.border = "#cccccc solid 1px";
            td6.style.borderLeft = "none";
            td6.style.borderTop = "none";
            tr.appendChild(td1);
            tr.appendChild(td2);
            tr.appendChild(td3);
            tr.appendChild(td4);
            tr.appendChild(td5);
            tr.appendChild(td6);
            t_table.appendChild(tr);
        }
    }

    function do_edit() {
        document.getElementById('new_models').style.display = 'none';
        var record_list =
        {{ data.record_list | safe }}
        var chencked_list = []
        var Jsondata = []
        var chencked_value_li = document.getElementsByClassName('radio-checkbox')
        for (var tt = 0; tt < chencked_value_li.length; tt++) {
            if (chencked_value_li[tt].checked) {
                chencked_list.push(chencked_value_li[tt])
            }
        }
        for (var i = 0; i < record_list.length; i++) {
            var record = record_list[i]
            if (record['type'] === 'checkbox') {
                for (var j = 0; j < chencked_list.length; j++) {
                    var chencked = chencked_list[j]
                    if (record['id'] === chencked.id) {
                        record['value'] = 'checked'
                        Jsondata.push({"id": record['id'], 'value': record['value'], 'type': record['type']})
                    }
                }
            } else if (record['type'] === "radio") {
                var radio_select = $('input[name=radio_button]:checked').val()       // 单选框值
                Jsondata.push({'value': radio_select, 'id': record_list[i]['id'], 'type': record['type']})
            } else {
                var value = document.getElementById(record_list[i]['id']).value    // 文本框，下拉框，时间框，多行文本框值
                Jsondata.push({'value': value, 'id': record_list[i]['id'], 'type': record['type']})
            }
        }
        console.log("Jsondata: ", Jsondata)
        const id =
        {{ data.id }}
        var xhr = new XMLHttpRequest();
        var local_host = window.location.host;          // 获取当前IP
        xhr.open('post', "/system-setup/Low_code_bill_write_view", true);
        xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
        xhr.send('data_html=' + JSON.stringify(Jsondata) + "&id=" + id + "&fj_number=" + String(uuid))
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    alert("提交成功！")
                    window.parent.location.reload()
                }
            }
        }
    }

    function upload_accessory(file_type, tbody_id, accessory_type) {
        var form = new FormData();
        var files = document.getElementById(accessory_type).files[0];
        form.append(file_type, files);
        form.append('number', uuid)
        form.append('source', 'zdy')

        var xhr = new XMLHttpRequest();
        var local_host = window.location.host;          // 获取当前IP
        xhr.open('post', "/administrative/topics_attachments_upload", true);
        xhr.send(form);
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    var JsonDate = JSON.parse(xhr.responseText);
                    console.log(JsonDate);
                    creat_table_0(JsonDate, tbody_id)
                }
            }
        };
    }

    // 创建附件列表
    function creat_table_0(JsonData, tbody_id) {
        var t_table = document.getElementById(tbody_id);
        var local_host = window.location.host;
        if (Array.isArray(JsonData["pdf_path"])) {
            for (var i = 0; i < JsonData["pdf_path"].length; i++) {
                var tr = document.createElement("tr");
                var td1 = document.createElement("td");
                var td2 = document.createElement("td");
                var td3 = document.createElement("td");
                var td4 = document.createElement("td");
                var td5 = document.createElement("td");
                var td6 = document.createElement("td");
                td1.innerHTML = t_table.children.length + 1;
                td1.style.textAlign = "center";
                td1.style.border = "#cccccc solid 1px";
                td1.style.borderTop = "none";
                td2.innerHTML = JsonData["file_name"];
                td2.style.paddingLeft = "1%";
                td2.style.border = "#cccccc solid 1px";
                td2.style.borderLeft = "none";
                td2.style.borderTop = "none";
                td3.innerHTML = JsonData["file_size"];
                td3.style.textAlign = "center";
                td3.style.border = "#cccccc solid 1px";
                td3.style.borderLeft = "none";
                td3.style.borderTop = "none";
                td4.innerHTML = JsonData["upload_time"];
                td4.style.textAlign = "center";
                td4.style.border = "#cccccc solid 1px";
                td4.style.borderLeft = "none";
                td4.style.borderTop = "none";
                td5.innerHTML = JsonData["uploader"];
                td5.style.textAlign = "center";
                td5.style.border = "#cccccc solid 1px";
                td5.style.borderLeft = "none";
                td5.style.borderTop = "none";
                td6.innerHTML = "<a target='_blank' href='" + JsonData["pdf_path"][i]["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["pdf_path"][i]["id"] + "\")'>删除</a>";
                td6.style.textAlign = "center";
                td6.style.border = "#cccccc solid 1px";
                td6.style.borderLeft = "none";
                td6.style.borderTop = "none";
                tr.appendChild(td1);
                tr.appendChild(td2);
                tr.appendChild(td3);
                tr.appendChild(td4);
                tr.appendChild(td5);
                tr.appendChild(td6);
                t_table.appendChild(tr);
            }
            if (JsonData["pdf_path"].length > 1) {
                document.getElementById("del_adjunct").style.display = 'block';
            }
        } else {
            var tr = document.createElement("tr");
            var td1 = document.createElement("td");
            var td2 = document.createElement("td");
            var td3 = document.createElement("td");
            var td4 = document.createElement("td");
            var td5 = document.createElement("td");
            var td6 = document.createElement("td");
            td1.innerHTML = t_table.children.length + 1;
            td1.style.textAlign = "center";
            td1.style.border = "#cccccc solid 1px";
            td1.style.borderTop = "none";
            td2.innerHTML = JsonData["file_name"];
            td2.style.paddingLeft = "1%";
            td2.style.border = "#cccccc solid 1px";
            td2.style.borderLeft = "none";
            td2.style.borderTop = "none";
            td3.innerHTML = JsonData["file_size"];
            td3.style.textAlign = "center";
            td3.style.border = "#cccccc solid 1px";
            td3.style.borderLeft = "none";
            td3.style.borderTop = "none";
            td4.innerHTML = JsonData["upload_time"];
            td4.style.textAlign = "center";
            td4.style.border = "#cccccc solid 1px";
            td4.style.borderLeft = "none";
            td4.style.borderTop = "none";
            td5.innerHTML = JsonData["uploader"];
            td5.style.textAlign = "center";
            td5.style.border = "#cccccc solid 1px";
            td5.style.borderLeft = "none";
            td5.style.borderTop = "none";
            td6.innerHTML = "<a target='_blank' href='" + JsonData["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["id"] + "\")'>删除</a>";
            td6.style.textAlign = "center";
            td6.style.border = "#cccccc solid 1px";
            td6.style.borderLeft = "none";
            td6.style.borderTop = "none";
            tr.appendChild(td1);
            tr.appendChild(td2);
            tr.appendChild(td3);
            tr.appendChild(td4);
            tr.appendChild(td5);
            tr.appendChild(td6);
            t_table.appendChild(tr);
        }
    }

    function RemoveTr(_this, tbody_id, wj_id) {
        var table = document.getElementById(tbody_id);
        var trNode = $(_this).parent().parent();
        trNode.remove();

        for (var i = 0; i < table.children.length; i++) {
            table.children[i].children[0].innerHTML = i + 1;
        }

        var xhr = new XMLHttpRequest();
        var local_host = window.location.host;          // 获取当前IP
        xhr.open('post', "/administrative/delete_attachments_view", true);
        xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
        xhr.send("id=" + String(wj_id));
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    // document.getElementById("loading").style.display = "none";
                    var JsonDate = JSON.parse(xhr.responseText);
                    console.log(JsonDate);
                    alert("删除成功！")
                }
            }
        };
    }
</script>
</body>

</html>

